package com.jobpass.utils;

import java.util.Random;

public class SaltUtils {

    /**
     * 生成salt的静态方法
     * @Author ZhangHuan
     * @Description //TODO
     * @Date 14:53 2020/7/22
     * @Param
     * @return
     **/
    public static String getSalt(int n){
        char[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+~()".toCharArray();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
          char aChar = chars[new Random().nextInt(chars.length)];
          sb.append(aChar);
        }
        System.out.println(sb.toString());
        return sb.toString();
    }

    public static void main(String[] args) {
        getSalt(8);
    }
}
